package com.revzone.demo001.entity.PermissionEntity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.revzone.demo001.entity.OtherEntity.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author lsa
 * @since 2023-04-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("user")
public class User extends BaseEntity<User> implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty("主键id")
    private Integer id;

    @TableField("user_name")
    @ApiModelProperty("姓名")
    private String userName;

    @TableField("nick_name")
    @ApiModelProperty("别名")
    private String nickName;

    @TableField("password")
    @ApiModelProperty("密码")
    private String password;

    @TableField("salt")
    @ApiModelProperty("盐")
    private String salt;

    @TableField("sex")
    @ApiModelProperty("性别")
    private Integer sex;

    @TableField("email")
    @ApiModelProperty("邮箱")
    private String email;

    @TableField("phone")
    @ApiModelProperty("电话")
    private String phone;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("创建时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("create_date")
    private Date createDate;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("修改时间")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField("update_date")
    private Date updateDate;

    @TableField("status")
    @ApiModelProperty("状态")
    private Integer status;

    @TableField("remarks")
    @ApiModelProperty("备注")
    private String remarks;

    @TableField(exist = false)//非数据库字段
    @ApiModelProperty("角色列表")
    private List<Role> roles; // 一个用户可以有多个角色

    @TableField("site_id")
    private Integer siteId;

}
